from django.db import models


class Book(models.Model):
    title = models.CharField(max_length=255, default='title')
    owned = models.IntegerField()
    price = models.FloatField()
    publish_date = models.DateField()
    category = models.ForeignKey('Category', on_delete=models.CASCADE)
    author = models.ForeignKey('Author', on_delete=models.CASCADE)

    def __str__(self):
        print("self.title", self.title)
        return self.title


class Author(models.Model):
    name = models.CharField(max_length=255, default='name')

    def __str__(self):
        return self.name


class Category(models.Model):
    title = models.CharField(max_length=100, default='title')

    def __str__(self):
        return self.title
